<?php
namespace Common\Model;

use Think\Model;

class SystemOrderModel extends \BaseModel
{
    public function load($order_sn)
    {
        $info = $this->where("order_sn='$order_sn'")->find();
        if ($info) {
            $info['user'] = BoxModel("system_member")->load($info['user_id']);
            $info['payment'] = BoxModel("SystemPayment")->load($info['payment_id']);
            hook("order_load", $info);
            hook("order_load_" . $info['order_type'], $info);
        }
        return $info;
    }
//支付成功
    public function paySuc($order_sn)
    {
        $info = $this->load($order_sn);
        $r = $this->where("order_sn='$order_sn'")->save(array('status' => 2, 'pay_time' => date("Y-m-d H:i:s")));
								if ($r) {
            hook("order_paySuc", $info);
            hook("order_paySuc_" . $info['order_type'], $info);
        }
        return $r;
    }
//已经发货
   public function logistics($order_sn,$id){
				  $info = $this->where("order_sn='$order_sn'")->find();
				  $r = $this->where("order_sn='$order_sn'")->save(array('status' => 4));
						if($id){
							$logistics=BoxModel("system_order_logistics")->where(array('id'=>$id))->find();
							$info['logistics']=$logistics;
       hook("order_logistics", $info);
       hook("order_logistics_" . $info['order_type'], $info);
						}
						return $r;
			}

}